<template>
    <div>
        <!-- 票价管理-票价调整记录 -->
        <el-row>
            <el-col :span="24">
                <div class="container">
                    <!-- 功能栏1 -->
                    <el-row class="head-fun">
                        <el-col :span="24">
                            <!-- 功能栏1 -->
                            <div class="choose-title lf">操作时间</div>
                            <el-date-picker type="date" v-model="dateFrom" style="width: 130px;" size="mini" class="lf choose-input"></el-date-picker>
                            <div class="lf choose-title">&nbsp; 至&nbsp;</div>
                            <el-date-picker type="date" v-model="dateTo" style="width: 130px;" size="mini" class="lf choose-input"></el-date-picker>
                            <button class="check-btn rf" @click="check"><img src="../../assets/imgs/operation_btn_icon_chaxun_default.png" alt="" class="btn-img">查询</button>
                        </el-col>
                    </el-row>
                    <!-- 功能栏2 -->
                    <el-row>
                        <el-col :span="24">
                            <img src="../../assets/imgs/operation_icon_huigun_default.png" alt="" class="choose-img"><span class="choose-title" @click="backTo">回滚</span>
                            <img src="../../assets/imgs/operation_icon_shousuo_default.png" alt="" class="choose-img"><span class="choose-title" @click="toDetail">查看明细</span>
                        </el-col>
                    </el-row>
                    <!-- 表格内容 -->
                    <el-row>
                        <el-col :span="24">
                            <avue-crud :data="priceChangeList[0].data" :option="priceChangeList[0].option"  @current-row-change="rowChange" :page="priceChangeList[0].page" @current-change="changPage"></avue-crud>    
                        </el-col>
                    </el-row>
                </div>
            </el-col>
        </el-row>
        
    </div>
</template>

<script>
import qs from "qs";
import TableData from "../../components/common/tableData"
export default {
  data: function() {
    return {
      activeTag: "3-4",
      dateFrom: "",
      dateTo: "",
      currentRow:"",
      priceChangeList: [
        {
          page: {
            pageSizes: [10],
            total: 2,
            currentPage: 1,
            pageSize: 10
          },
          data: [],
          option: {
            highlightCurrentRow:true,
            page: true,
            stripe: true,
            menu: false,
            align: "center",
            menuAlign: "center",
            column: []
          }
        }
      ],
      backID: {
        id: 0
      },
      detailRules: {
        sort: "line.code",
        order: "asc",
        page: "1",
        rows: "6"
      }
    };
  },
  methods: {
    changPage(val){
      this.priceChangeList[0].page.currentPage=val;
      this.getList();
    },
    getList() {
      this.
        postRequest("/sch/bus/price/manage/list",{
          rows:10,
          page:this.priceChangeList[0].page.currentPage
        })
        .then(data => {
          console.log(data);
          this.priceChangeList[0].page.total=data.data.totalRow;
          for (var item of data.data.list) {
            this.priceChangeList[0].data=data.data.list;
          }
        });
    },
    backTo() {
      this
        .postRequest(
          "/sch/bus/price/manage/doRollbackCustomAdjust",{
            id:this.currentRow
          }
        )
        .then(data => {
          // console.log(data);
          this.msgShow(data,function(){})
        });
    },
    toDetail() {
      this.$http
        .post(
          "/sch/bus/price/manage/details",
          JSON.stringify({
            filterRules: [{"field":"pa.id","op":"eq","value":0}],
            page: '1',
            rows: '6',
            order: 'asc'
          })
        )
        .then(data => {
          console.log(data);
        });
    },
    tableCreate() {
      this.priceChangeList[0].option.column.push(
        {
          label: "标题",
          prop: "remark"
        },
        {
          label: "班次日期",
          prop: "bus_date_end"
        },
        {
          label: "调整方案",
          prop: "adjust_type"
        },
        {
          label: "参数",
          prop: "adjust_para"
        },
        {
          label: "线路筛选",
          prop: "line_names"
        },
        {
          label: "站点筛选",
          prop: "st_id"
        },
        {
          label: "影响线路",
          prop: "line_count"
        },
        {
          label: "影响班次",
          prop: "bus_plan_count"
        },
        {
          label: "票型筛选",
          prop: "price_types"
        },
        {
          label: "状态",
          prop: "status"
        },
        {
          label: "操作时间",
          prop: "update_time"
        },
        {
          label: "操作人",
          prop: "update_user"
        },
      );
    },
    check(){
      this.postRequest("/sch/bus/price/manage/list",{
        filterRules:JSON.stringify([
          {"field":"create_time","op":"dge","value":this.dateToString(this.dateFrom)},
          {"field":"create_time","op":"dle","value":this.dateToString(this.dateTo)}
        ])
      }).then(data=>{
        this.priceChangeList[0].data=data.data.list;
      })
    },
    rowChange(val){
      this.currentRow=val.id
    }
  },
  computed: {},
  components:{TableData},
  watch: {},
  mounted() {
    console.log("changeList");
    this.$emit("sendActive", this.activeTag);
    this.tableCreate();
    this.getList();
  }
};
</script>
<style scoped src="../../assets/css/service/changeList.css">
</style>